// src/main/db/index.js
const Sequelize = require('sequelize')
const config = require('../config/index.js')
const requireDirectory = require('require-directory')

// console.log(config.db);
const sequelize = new Sequelize(config.db);

// 加载模型
requireDirectory(module, '../models', {
  visit: (obj) => {
    if (obj.modelName) {
      sequelize.define(obj.modelName, obj.attributes, obj.options);
	  sequelize.sync({
		  force: false
	  });
    }
  }
});

module.exports = sequelize
